package headfirst.designpatterns.factory.a_cars_simplefactory2.z_run_test;

import headfirst.designpatterns.factory.a_cars_simplefactory2.boss.BossCall;
import headfirst.designpatterns.factory.a_cars_simplefactory2.car.Car;
import headfirst.designpatterns.factory.a_cars_simplefactory2.factory.DriverSimplyFactory;

import java.io.IOException;

/**
 * @description: 老板（使用者）测试
 * @author: 陈家盛
 * @date: 2022/6/22 10:25
 * @version: 1.0
 */
class BossCallTest {

    public static void main(String[] args) throws IOException {


        /**
         * 可以直接通过工厂创建
         * 有业务需求也可以根据业务多一层，在这一层使用工厂创建（为工厂方法铺垫？）
         */

        // 老板告诉司机我今天坐 奔驰
        DriverSimplyFactory factory = new DriverSimplyFactory();
        BossCall call = new BossCall(factory);
        Car car1 = call.callCar("benz");
        car1.setName("benz");
        // 司机开着 奔驰 出发
        car1.drive();


        // 老板告诉司机我今天坐 宝马
        Car car2 = factory.createCar("Bmw");
        car2.setName("Bmw");
        // 司机开着 宝马 出发
        car2.drive();


    }
}
